<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<title></title>
<link href="<s:url value='/common/lib/ligerUI/skins/Aqua/css/ligerui-all.css'/>" rel="stylesheet" type="text/css" />
<link href="<s:url value='/common/lib/ligerUI/skins/ligerui-icons.css'/>" rel="stylesheet" type="text/css" />
<script src="<s:url value='/common/lib/jquery/jquery-1.3.2.min.js'/>" type="text/javascript"></script>
<script src="<s:url value='/common/lib/ligerUI/js/core/base.js'/>" type="text/javascript"></script>
<script src="<s:url value='/common/lib/ligerUI/js/plugins/ligerDialog.js'/>" type="text/javascript"></script>
<style type="text/css">
	.box {margin-top: 20px; margin-left: 20px;}
	.btn {background-color:#FFF; border:1px solid #CDCDCD; width:60px;}
</style>
<script type="text/javascript">
	$(function(){
		$("#uploadDateBox").hide();
		$("#dealerCode").focus();
	});
	
	function getDateList() {
		var dc = $("#dealerCode").val();
		if(dc != null && dc != '') {
			$.post("<s:url value='/record/validDealerCode.action'/>",{dealerCode : dc}, function(data) {
				if(data != 0) {
					$.ligerDialog.alert('您输入的经销商网代码有误，请重新输入!', '提示', 'error');
					$("#dealerCode").val("");
					$("#dealerCode").focus();
				} else {
					$.post("<s:url value='/record/getStroragePaths.action'/>",{dealerCode : dc}, function(data) {
		         		var datas = data.split(":");
		         		if(datas[0] == 0) {
		         			$("#dealerCode").attr("disabled", "disabled");
		 					$("#dcButton").attr("disabled", "disabled");
		 					$("#uploadDateBox").show();
		         			$("#uploadDate").prepend("<option value='0'>请选择...</option>");
		         			var dirs = datas[1].split(",");
		         			for(var i = 0; i < dirs.length; i++) {
		         				var dir = dirs[i].replace(/\n/g, "").replace(/\r/g, "");
		         				$("#uploadDate").append("<option value='" + dir + "'>" + dir + "</option>");
		         			}
		         			$("#uploadDate").change(function(){
		     					var val = $("#uploadDate").val();
		     					if(val != 0) {
		     						viewOutOfSystemRecord(dc, val);
		     					}
		     				});
		         		} else {
		         			$.ligerDialog.alert('该经销商尚未上传数据!', '提示', 'none'); 
		         		}
		         	});
				}
			});
		} else {
			$.ligerDialog.alert("请输入经销商代码", "错误", "error");
		}
	}
	
	function viewOutOfSystemRecord(dc, uDate) {
		$("#resultList").children().remove();
		$.post("<s:url value='/record/viewOutOfSystemRecord.action'/>",{dealerCode:dc, timeStamp:uDate}, function(data) {
     		var results = data.split(":");
     		if(results[0] == 0) {
     			$("#resultTip").text("系统外文件列表:");
     			var fileNames = results[1].split(",");
     			for(var i = 0; i < fileNames.length; i++) {
     				var fileName = fileNames[i].replace(/\n/g, "").replace(/\r/g, "");
     				$("#resultList").append("<li>" + fileName + "</li>");
     			}
     		} else {
     			$("#resultTip").text("该经销商无系统外文件");
     		}
     	});
	}
</script>
</head>
<body>
	<div class="box">
		<div>
			<label for="dealerCode">请输入经销商代码：</label>
			<input id="dealerCode" type="text" style="width: 120px;"/>
			<input id="dcButton" type="button" onclick="getDateList()" class="btn" value="确定"/>
		</div>
		<div style="margin-top: 5px;" id="uploadDateBox">	
			<label for="uploadDate" style="padding-right: 11px;">请选择上传时间：</label>
			<select id="uploadDate" style="width: 123px;"></select>
		</div>
	</div>
	
	<div class="box" id="resultBox">
		<h4><span id="resultTip"></span></h4>
		<div>
			<ul id="resultList">
			</ul>
		</div>
	</div>
</body>
</html>